package com.yanqu.road.server.cmd.beautyescort;

import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.pb.beautyescort.BeautyEscortProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.manger.beautyescort.BeautyEscortMgr;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;
import io.netty.channel.ChannelHandlerContext;

@Cmd(code = Protocol.S_BEAUTY_ESCORT_GET_UNION_MEMBER_DATA_FROM_CROSS, desc = "商会榜单贡献(跨服来查)")
public class BeautyEscortRankMemberDataCmdFromCrsss implements Command {

    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage packet) throws Exception {
        BeautyEscortProto.CrossBeautyEscortRankMemberDataReqMsg reqMsg = BeautyEscortProto.CrossBeautyEscortRankMemberDataReqMsg.parseFrom(packet.getBytes());

        BeautyEscortProto.CrossBeautyEscortRankMemberDataRespMsg.Builder respMsg = BeautyEscortProto.CrossBeautyEscortRankMemberDataRespMsg.newBuilder();
        respMsg.addAllData(BeautyEscortMgr.getUnionRankMemberDataTemp(reqMsg.getWeekId(), reqMsg.getUnionUid()));
        respMsg.setRet(0);
        respMsg.setPlayerId(reqMsg.getPlayerId());
        respMsg.setPlayerServerId(reqMsg.getPlayerServerId());
        //回包给跨服
        GamePlayerMgr.sendPacket(0, YanQuMessageUtils.buildMessage(Protocol.C_BEAUTY_ESCORT_GET_UNION_MEMBER_DATA_TO_CROSS, respMsg));
    }
}
